package dk.dashboardFP.contextPanel {
	import dk.dashboardFP.core.EDashboardFPDefaultSettings;
	import dk.dashboardFP.core.DashboardFPSettings;
	import dk.dashboardFP.panels.ui.graphics.GradBlock;

	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	/**
	 * @author josef
	 */
	public class AbstractContextPanel extends Sprite {

		private var _pGlobalPosition : Point;
		protected var _sprPanelContent : Sprite;
		private var _doBackBlock : GradBlock;
		private var _oDashboardFPSettings : DashboardFPSettings = DashboardFPSettings.get_oInstance();
		private var _nMargin : Number = 8;

		public function AbstractContextPanel(pGlobalPosition : Point) {
			
			_pGlobalPosition = pGlobalPosition;
			
			//:::::::
			// set position 
			x = _pGlobalPosition.x;
			y = _pGlobalPosition.y;
			
			//:::::::
			// containers 
			_sprPanelContent = new Sprite();
			addChild(_sprPanelContent);
		}

		protected function drawPanelBack(pSize : Point) : void {
			
			_doBackBlock = new GradBlock();
			addChildAt(_doBackBlock, 0);
			
			_doBackBlock.x = -_nMargin;
			_doBackBlock.y = -_nMargin;
			
			_doBackBlock.drawBlock(new Rectangle(0, 0, pSize.x + _nMargin * 2, pSize.y + _nMargin * 2), EDashboardFPDefaultSettings.nPANEL_BACK_ROUNDING);

			_doBackBlock.uintTopColor = 0x222628;
			_doBackBlock.uintBottomColor = 0x58666e;
			
			updatePanelBackAlpha();
			updatePanelBackShadow();
		}

		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// update back settings
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

		private function updatePanelBackAlpha() : void {
			_doBackBlock.nAlpha = _oDashboardFPSettings.nPanelBackAlpha;
		}

		private function updatePanelBackShadow() : void {
			_doBackBlock.bShadowEnabled = _oDashboardFPSettings.bShadowsEnabled;
		}
	}
}
